<?php
/**
 * Created by PhpStorm.
 * User: liujun
 * Date: 2018/8/9
 * Time: 上午10:05
 */

namespace PddWechat\Models\User\Dao;

/**
 * Class UserDao
 *
 * @package PddWechat\Models\User\Dao
 */

use Dai\Framework\Base\BaseDao;
use PddWechat\Models\User\DataObject\UserPromotionUrlDo;

/**
 * Class UserPromotionUrlDao
 * @package PddWechat\Models\User\Dao
 * @dataObject(\PddWechat\Models\User\DataObject\UserPromotionUrlDo)
 */
class UserPromotionUrlDao extends BaseDao
{
    /**
     * @param UserPromotionUrlDo $userDo
     * @return UserPromotionUrlDo
     */
    public function insert( UserPromotionUrlDo $userDo )
    {
        $userDo->id =  $this->execute("user.user_promotion_url.insert", $userDo);
        return $userDo;
    }


    /**
     * @param $openId
     * @return null|UserPromotionUrlDo
     */
    public function selectByOpenId($openId)
    {
        $param = [
            'openId' => $openId,
            'select' => '*',
        ];
        $res = $this->execute("user.user_promotion_url.select_by_open_id", $param);
        if( count($res) > 0 ) {
            /** @var UserPromotionUrlDo $ret */
            $ret = $this->trimBase($res[0]);
            return $ret;
        }
        return null;
    }
}